// Judicial Decisions, Police Officer Uncertainty, and the Escalation of Force //
// Courtenay R. Monroe, Sophia Hatz and Kristine Eck//
// EXCLUDING CORRECTIONS CASES
// December 2023 //
// note: this code draws on replication for de Chaisemartin and Hoetfouille 2020


ssc install did_multiplegt, replace
ssc install estout, replace

clear

use "JD_replication_data_nc.dta"


// set panel data set

xtset state year


// make dummy variables for year
tab year, gen(d)
// make dummy variables for state
tab state, gen(st)



* table 8 in the appendix
qui{

// m1
set seed 1
did_multiplegt police_shoot_fe state year restrictive_aele, breps(200) cluster(state)
graph drop _all 
scalar did_m1=e(effect_0)
scalar se_did_m1 = e(se_effect_0)
scalar N_did_m1 = e(N_effect_0)
scalar t_stat_m1 = e(effect_0)/e(se_effect_0)
scalar p_val_m1 = 2*normal(-abs(t_stat_m1))


// m1b
set seed 1
did_multiplegt police_shoot_fe state year restrictive_aele, controls(homicide_rate_ucr property_crime_rate_ucr) breps(200) cluster(state)
graph drop _all 
scalar did_m1b=e(effect_0)
scalar se_did_m1b = e(se_effect_0)
scalar N_did_m1b = e(N_effect_0)
scalar t_stat_m1b = e(effect_0)/e(se_effect_0)
scalar p_val_m1b = 2*normal(-abs(t_stat_m1b))

// m2
set seed 1
did_multiplegt police_shoot_fe state year restrictive_count_aele, recat_treatment(restrictive_count_aele_recat) breps(200) cluster(state)
graph drop _all 
scalar did_m2=e(effect_0)
scalar se_did_m2 = e(se_effect_0)
scalar N_did_m2 = e(N_effect_0)
scalar t_stat_m2 = e(effect_0)/e(se_effect_0)
scalar p_val_m2 = 2*normal(-abs(t_stat_m2))

// m2b
set seed 1
did_multiplegt police_shoot_fe state year restrictive_count_aele, recat_treatment(restrictive_count_aele_recat) controls(homicide_rate_ucr property_crime_rate_ucr) breps(200) cluster(state)
graph drop _all 
scalar did_m2b=e(effect_0)
scalar se_did_m2b = e(se_effect_0)
scalar N_did_m2b = e(N_effect_0)
scalar t_stat_m2b = e(effect_0)/e(se_effect_0)
scalar p_val_m2b = 2*normal(-abs(t_stat_m2b))



matrix res1 = (did_m1, se_did_m1,t_stat_m1,p_val_m1, N_did_m1\ ///
			  did_m1b, se_did_m1b,t_stat_m1b,p_val_m1b, N_did_m1b\ ///
			  did_m2, se_did_m2,t_stat_m2,p_val_m2, N_did_m2\ ///
			  did_m2b, se_did_m2b,t_stat_m2b,p_val_m2b, N_did_m2b)
			  
matrix rownames res1=m1 m1b m2 m2b 
matrix colnames res1=estimate se tstat pval N
}

// 
matrix list res1

putexcel set "table8", replace
putexcel A1=matrix(res1), names


